package com.laopan.elasticsearch.bean.geo;

import com.laopan.elasticsearch.bean.Field;
import org.elasticsearch.index.query.GeoDistanceQueryBuilder;

import java.util.List;

/**
 * 中心点查询信息
 *
 * @author laopan
 * @className CenterRange
 * @date 2021/4/20 13:55
 */
public class CenterRange {
    private String distance;
    private Location centerPoint;
    private Location distancePoint;
    private List<Field> queryFields;

    public String getDistance() {
        return distance;
    }

    public void setDistance(String distance) {
        this.distance = distance;
    }

    public Location getCenterPoint() {
        return centerPoint;
    }

    public void setCenterPoint(Location centerPoint) {
        this.centerPoint = centerPoint;
    }

    public Location getDistancePoint() {
        return distancePoint;
    }

    public void setDistancePoint(Location distancePoint) {
        this.distancePoint = distancePoint;
    }

    public List<Field> getQueryFields() {
        return queryFields;
    }

    public void setQueryFields(List<Field> queryFields) {
        this.queryFields = queryFields;
    }

    public GeoDistanceQueryBuilder geoQueryBuilder(String fieldName) {
        return getCenterPoint().geoQueryBuilder(fieldName, getDistance());
    }
}
